package com.xinnet.mms.allot.dao.impl;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.xinnet.core.dao.impl.BaseDaoImpl;
import com.xinnet.core.utils.page.PageView;
import com.xinnet.mms.allot.dao.CustomAllotConfigCheckDao;
import com.xinnet.mms.entity.CustomAllotConfigDept;
import com.xinnet.mms.entity.Dept;

@Repository("allotConfigCheckDao")
public class CustomAllotConfigCheckDaoImpl extends BaseDaoImpl<CustomAllotConfigDept, Long> implements CustomAllotConfigCheckDao {

	/**分页查询在审核状态的客户分配设置*/
	@Override
	public PageView<CustomAllotConfigDept> queryAllotConfigCheck(PageView<CustomAllotConfigDept> pageView) throws SQLException {
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("paging", pageView);
		pageView.setRecords(this.getSqlSession().selectList("customerallot"+".queryAllotConfigCheck",map));
		if(pageView.getRecords().isEmpty())
			return null;
		return pageView;
	}
	
	public List<CustomAllotConfigDept> getAllotConfigCheck(String deptIdStr) throws SQLException {
		List<CustomAllotConfigDept> customAllotConfigDeptList = this.getSqlSession().selectList("customerallot.getAllotConfigCheck",deptIdStr);
		return customAllotConfigDeptList;
	}
	
	/**通过组织结构名称过滤审核状态的客户分配设置*/
	@Override
	public PageView<CustomAllotConfigDept> queryAllotConfigCheckByDname(PageView<CustomAllotConfigDept> pageView, Dept dept) throws SQLException {
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("paging", pageView);
		map.put("t", dept);
		pageView.setRecords(this.getSqlSession().selectList("customerallot"+".quertAllotConfigCheckByDname",map));
		if(pageView.getRecords().isEmpty())
			return null;
		return pageView;
	}

	/**根据部门ID将分配设置设置为启用*/
	@Override
	public void updateAllotConfigCheckResultYes(String deptno) throws SQLException {
		this.getSqlSession().update("customerallot.updateAllotConfigCheckResultYes",deptno);
	}

	/**根据部门ID将分配设置设置为拒绝*/
	@Override
	public void updateAllotConfigCheckResultNo(String deptno) throws SQLException {
		this.getSqlSession().update("customerallot.updateAllotConfigCheckResultNo",deptno);
	}

}
